package com.ifast.common.utils;

import java.util.ArrayList;
import java.util.Date;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.google.common.collect.Lists;
import com.xiaoleilu.hutool.date.DatePattern;
import com.xiaoleilu.hutool.date.DateTime;
import com.xiaoleilu.hutool.date.DateUtil;


/**
 * 项目名称：
 * 修改日期：2015/11/2
*/
public class Const { 
	
	public static final int loops = 5;//默认轮播图片数量
	
	public static final int dwCodeSubLength = 8;//单位code截取长度
	   
	public static long SMS_TIME_OUT = 60;//秒
	/**
	 * 督查考核短信APP_ID(腾讯云)
	 */
	public static final int APP_ID = 1;

	/**
	 * 督查考核短信APP_KEY(腾讯云)
	 */
	public static final String APP_KEY = "";
	
	/**
	 * 手机号国家码
	 */
	public static final String NATION_CODE = "86";
	
	/**
	 * 短信签名
	 */
	public static final String SIGN = "";
	
	/**
	 * 短信异常是否警报
	 */
	public static final boolean SMS_ERR_ALARM = true;
	
	/**
	 * 短信异常警报电话
	 */
	public final static ArrayList<String> SMS_ERR_PHONE = Lists.newArrayList("115247648452");
	 
	
	/**
	 * 考核测评统计精确位数---小数点后两位
	 */
	public final static int scale =2;
	public final static int scale4 =4;


	/**
	 * 工作日志统计连续未填报次数
	 */
	public final static int lxwtbcs = 3;

	/**
	 * 默认密码
	 */
	public final static String password="1";

	/**
	 * 家庭成员关系gValue
	 */
	public final static String jtcyGx = "jtcygx";
	public final static String zzmm = "zzmm";


	/**
	 * 用户类型id
	 */
	public final static String ptyh = "DBAA0D17E13240FFAA7E9555CCD64791";

	private Const() {}
	
	/**每个相册的大小 100m*/
	public final static int everyAlbumSize = 100 * 1024 * 1024;
	/**用户所用相册的大小 1000m*/
	public final static int maxAlbumSize = 10 * 100 * 1024 * 1024;
	
	/**app 1000m*/
	public final static int maxApkSize = 10 * 100 * 1024;
	/**相册*/
	public enum album {
		album_nomal("album_nomal","DE4846A8EFE0424BA188B95BF09DB1A5","普通相册"), 
		album_loop("album_loop","44C4E33A36244568AC0199D4ADF0D71E","轮播相册");
		private String value;private String id;private String name;
		private album(String value,String id,String name) {this.value = value;this.id = id;this.name = name;} 
		public String getValue(){return value;}
		public String getName(){return name;}
		public String getId(){return id;} 
	}
	/**相册*/
	public enum albumDoType {
		type_nomal(0,"普通用途"), 
		type_loop(1,"企业轮播相册");
		private int value;private String name;
		private albumDoType(int value,String name) {this.value = value;this.name = name;} 
		public int getValue(){return value;}
		public String getName(){return name;}
		 
	}
	/**新闻分类*/
	public enum news{ 
		news("news","F642C63D392B46E08DB92FA5250FCC6D","新闻分类"),
		news_information("news_information","03BFCC4B73C545EAB913CFC97DCEB30F","新闻资讯"),
		news_safe("news_safe","60405B814FEB4C279EC84471BD20FB4A","安全知识"), 
		news_example("news_example","5EE11AECCE8342C99F6D4295D8C0C90C","安全案例"), 
		news_law("news_law","3C5BCE423AD844DF9D47231E53D6C0AC","法律法规"), 
		news_policy("news_policy","EF9A531BD8BA404083D17B743BD82D9C","政策文件"); 
		private String value;private String id;private String name;
		private news(String value,String id,String name) {this.value = value;this.id = id;this.name = name;} 
		public String getValue(){return value;}
		public String getName(){return name;}
		public String getId(){return id;} 
	}
	
	public enum help{  
		help("help","4DD9C571B8BF4D629B64F95042746430","使用手册相关"), 
		help_help("help_help","F4D2CC1D983F4D59AF4FFE8F1F932C7D","使用手册"), 
		help_about_ours("help_about_ours","C70A6E2AE90E409780E5CFC9331AC5C7","关于我们"), 
		help_agreement("help_agreement","AD1A467D9B60409FA9FC8F35784421C9","服务协议"); 
		private String value;private String id;private String name;
		private help(String value,String id,String name) {this.value = value;this.id = id;this.name = name;} 
		public String getValue(){return value;}
		public String getName(){return name;}
		public String getId(){return id;} 
	}
	
	/**新闻类型*/
	public enum newsType{ 
		news_type_text("news_type_text","A69CAECBF07143D58471104829527B74","文本新闻"),
		news_type_picture("news_type_picture","059607FBE17D43FCB18C8BA9179C1681","图文新闻"),
		news_type_video("news_type_video","9FF2C95C723F4261A787465EBC650D7D","视频新闻"); 
		private String value;private String id;private String name;
		private newsType(String value,String id,String name) {this.value = value;this.id = id;this.name = name;} 
		public String getValue(){return value;}
		public String getName(){return name;}
		public String getId(){return id;} 
	}
	
	/**新闻类型*/
	public enum versionType{ 
		create(0,"创建状态"),
		wait(1,"代考状态"),
		finish(2,"考完状态"); 
		private int value;private String name;
		private versionType(int value,String name) {this.value = value;this.name = name;} 
		public int getValue(){return value;}
		public String getName(){return name;}
	}
	
	/**积分说明类型*/
	public enum integralExplain {
		/**问答*/
		ask("integral_ask","5E55C35D29234212A38F37E6511605ED"),
		/**警告*/
		warn("integral_warn","DB45667BD98242CC80CB972AC415FA43"),
		/**规则*/
		rule("integral_rule","8219DCF720F947619FEBC8F64C2EFCAF");  
		private String value;private String id;
		private integralExplain(String value,String id){this.value = value;this.id = id;} 
		public String getValue(){return value;} 
		public String getId(){return id;} 
	}
	
	/**积分规则类型*/
	public enum integral { 
		integral_learn("integral_learn","BDCD79A381454600B2852E8450851186","学习积分"), 
		integral_read("integral_read","5EFA1D416FED4806A301F190E5CDFA88","阅读积分"), 
		integral_one_week("integral_one_week","F17D35D8F81A4C3C9B242D992CF68C2E","每周一答积分"), 
		integral_one_day("integral_one_day","68B889BFD8604428A211C97F04E88645","每日一题积分"), 
		integral_smart("integral_smart","37FEB49D7E2240F5ACFB3B31D8B20AF2","智能答题积分"), 
		integral_formal("integral_formal","A8BCA9DBED88403C84A23A76000CEC5E","专题考试积分"), 
		integral_share("integral_share","6E41AB069D784F35AFF6118F75F4113B","分享积分"), 
		integral_photo("integral_photo","74F5F89E6BF14DD0B3F13E1F65255BB8","照片上传积分"), 
		integral_login("integral_login","786247198E684680928ECB051ABEC794","登录积分");
		private String value;private String id;private String name;
		private integral(String value,String id,String name) {
			this.value = value;this.id = id;this.name = name;
		}
		public String getValue(){return value;}
		public String getId(){return id;}
		public String getName(){return name;}
		public static integral getIntegralBySmartExamId(String id){
			integral type = integral_one_day;
	    	if(smartExam.one_day_exam.getId().equals(id)){
	    		type = integral_one_day; 
	    	}else if(smartExam.one_week_exam.getId().equals(id)){
	    		type = integral_one_week;
	    	}else if(smartExam.any_time_exam.getId().equals(id)){
	    		type = integral_smart;
	    	}else if(smartExam.formal_exam.getId().equals(id)){
	    		type = integral_formal;
	    	} 
	    	return type;
		}  
	}
	
	/**积分是否开启*/
	public enum integralOpen {
		no(0),yes(1); 
		private int value;
		private integralOpen(int value){this.value = value;}
		public int getValue(){return value;}
	}
	
	/** 试卷类型*/
	public enum smartExam {
		/**每日一题*/
		one_day_exam("one_day_exam","E3485CD63E944B5F9F2DC9CB9F9C6C91",1),
		/**每周一题*/
		one_week_exam("one_week_exam","32CABEB6A13748BFB7AB97133C117849",5),
		/**智能答题*/
		any_time_exam("any_time_exam","03B0068FE2F54028A8A20C4FFB1E3463",5),
		/**专题考试答题*/
		formal_exam("formal_exam","D519D15A83284C29824E26707FA8DE85",0);
		
		private String value;private String id;private int count;
		private smartExam(String value,String id,int count) {
			this.value = value;this.id = id;this.count = count;
		}
		public String getValue(){return value;}
		public String getId(){return id;}
		public int getCount(){return count;}
	}
	/**类型*/
	public enum DelEnum {
		/**未删除*/
		no("0"),
		/**已删除*/
		yes("1"); 
		private String value;
		private DelEnum(String value){this.value = value;}
		public String getValue(){return value;}
	}

	/**新闻分类*/
	public enum transCode{ 
		need_trans(0,"未转"), 
		fail_trans(3,"失败"),
		success_trans(1,"已转");
		private int value;private String name;
		private transCode(int value,String name) {this.value = value;this.name = name;} 
		public int getValue(){return value;}
		public String getName(){return name;} 
	}
	
	
	 
	/**
	 *  类型   0 单位  1人员
	 */
	public enum DwOrRyEnum {

		dw("0"),
		ry("1");

		private String value;

		DwOrRyEnum(String value) {
			this.value = value;
		}

		public String getValue() {
			return value;
		}
	}


	/**
	 *  类型   0 1单位多人  1多单位多人  2 单位
	 */
	public enum KhcpTypeEnum {

		zero(0),
		one(1),
		two(2);

		private Integer value;

		KhcpTypeEnum(Integer value) {
			this.value = value;
		}

		public Integer getValue() {
			return value;
		}
	}



	public static String uuid(){
		return UUID.randomUUID().toString().trim().replaceAll("-", "");
	}


	private static Pattern humpPattern = Pattern.compile("[A-Z]");
	/** 驼峰转下划线,效率比上面高 */
	public static String humpToLine2(String str) {
		Matcher matcher = humpPattern.matcher(str);
		StringBuffer sb = new StringBuffer();
		while (matcher.find()) {
			matcher.appendReplacement(sb, "_" + matcher.group(0).toLowerCase());
		}
		matcher.appendTail(sb);
		return sb.toString();
	}

	public static void main(String[] args) {
		System.out.println(humpToLine2("ljXxcs"));
	}

	public static String version(){
		DateTime dateTime = new DateTime(DateUtil.now(), DatePattern.NORM_DATETIME_FORMAT);
		Integer month = dateTime.month()+1;
		String monthStr;
		if(month < 10){
			monthStr = "0"+month;
		}else{
			monthStr = month+"";
		}
		Integer day =  dateTime.dayOfMonth();
		String dayStr;
		if(day < 10){
			dayStr = "0"+day;
		}else{
			dayStr = day+"";
		}
		return dateTime.year()+""+monthStr+""+dayStr;
	}

	public static String get32UUID(){
		return UUID.randomUUID().toString().trim().replaceAll("-", "");
	}

	/**
	 * 获取季度
	 * @param dateStr
	 * @return
	 */
	public static int season(Date dateStr){
		return DateUtil.month(dateStr)/3+1;
	}


	
	
	
	
	public enum  DelState{
		ndel(0),
		del(1);
		private Integer value;
		public Integer getValue() {
			return value;
		}
		DelState(Integer value) {
			this.value = value;
		}
	}

}
